home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Tool Chest / Testing & Debugging / Hardware tools / HW Bring-up Tools / RW8.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-09-17  |  1.2 KB  |  66 lines  |  [TEXT/MPS ]

  1. #include <Types.h>
  2. #include <StdIO.h>
  3.  
  4. #define numRdArgs    2        /* Number of arguments for read command.    */
  5. #define numWrArgs    3        /* Number of arguments for write command.    */
  6.  
  7. #define kCommandArg 0
  8. #define kAddrArg 1
  9. #define kDataArg 2
  10.  
  11. typedef unsigned long ulong ;
  12. typedef unsigned char ubyte ;
  13.  
  14. //
  15. // Main()
  16. //
  17. unsigned main(ulong argC, char *argV[])
  18.  
  19. {    
  20.     ulong    status = noErr;
  21.  
  22.     if ((argC >= 2) && (argC <= 3))
  23.     {    
  24.         ubyte *address;
  25.     
  26.         sscanf(argV[kAddrArg],"%i", &address);
  27.         
  28.         if(true /*IN_RANGE(address, VBLInt, CurLine)*/)
  29.         {    
  30.             ubyte writeValue, readValue ;
  31.             ulong longWriteValue ;
  32.         
  33.             switch(argC)
  34.             {    
  35.             case numRdArgs:
  36.                 readValue = *address ;
  37.                 
  38.                 fprintf(stdout,"$%p -> $%02X (%d)\n",
  39.                         address, readValue, readValue);
  40.             break;
  41.             
  42.             case numWrArgs:
  43.                 sscanf(argV[kDataArg], "%i", &longWriteValue);
  44.                 writeValue = longWriteValue ;
  45.                 *address = writeValue ;
  46.                 fprintf(stdout,"$%p <- $%02X (%d)\n",
  47.                         address, writeValue, writeValue);
  48.             break;
  49.             
  50.             default:
  51.                 status++;
  52.             break;
  53.             }
  54.         }
  55.         else
  56.             status++;
  57.         }
  58.     else
  59.         status++;
  60.  
  61.     if (status != noErr)
  62.         fprintf(stdout,"# Usage %s - address [value].\n", argV[kCommandArg]);
  63.  
  64.     return(status);
  65.     }
  66.